
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('comCrime produces correct results robust_bayarri1', {
    set.seed(2019)
    comCrime <- get_comCrime()
    vy <- comCrime$vy
    mX <- comCrime$mX
    tic('comCrime produces correct results robust_bayarri1')
    result <- sampler(100000, vy, mX, prior='robust_bayarri1', modelprior='uniform', cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.9558700000000000,0.8629100000000000,0.2797800000000000,0.8637200000000000,
0.2550600000000000,0.6528100000000000,0.2287700000000000,0.3950700000000000,
0.2552300000000000,0.5435300000000000,0.4446000000000000,0.4110000000000000,
0.2342400000000000,0.2766700000000000,0.1507200000000000,0.1640300000000000,
0.2393100000000000,0.2202900000000000,0.3486100000000000,0.1979000000000000,
0.3426700000000000,0.2858000000000000,0.3641700000000000,0.2494500000000000,
0.2313000000000000,0.1853100000000000,0.2577300000000000,0.1995100000000000,
0.4929700000000000,0.2511600000000000,0.5707100000000001,0.1920000000000000,
0.1903100000000000,0.2306600000000000,0.3552500000000000,0.2001900000000000,
0.2162900000000000,0.2158000000000000,0.2012200000000000,0.8101400000000000,
0.3177900000000000,0.2259300000000000,0.3815600000000000,0.6185400000000000,
0.2895700000000000,0.4835000000000000,0.1760600000000000,0.1800300000000000,
0.8663100000000000,0.9680200000000000,0.9663500000000000,0.1726300000000000,
0.2432900000000000,0.2847100000000000,0.6304200000000000,0.1955800000000000,
0.2720200000000000,0.2349300000000000,0.2168200000000000,0.3333400000000000,
0.2034600000000000,0.3970400000000000,0.2986500000000000,0.3496700000000000,
0.4145400000000000,0.3834900000000000,0.3844200000000000,0.7272800000000000,
0.2260000000000000,0.1531200000000000,0.9433100000000000,0.2739600000000000,
0.3681500000000000,0.1761500000000000,0.2593500000000000,0.1710300000000000,
0.2370200000000000,0.3785900000000000,0.4004800000000000,0.3013000000000000,
0.3312800000000000,0.1895500000000000,0.2168000000000000,0.5435700000000000,
0.3488400000000000,0.1587200000000000,0.7543700000000000,0.2025700000000000,
0.3811400000000000,0.6143200000000000,0.1734900000000000,0.1976700000000000,
0.8639000000000000,0.2295000000000000,0.2074600000000000,0.1648000000000000,
0.1541600000000000,0.1549600000000000,0.9504100000000000
)
, tolerance = 1e-8)
})